package dao

import (
	"cachecron/global"
	"fmt"
	"github.com/go-sql-driver/mysql"
	"time"
)

/*缓存数据插入*/
func InsertCacheData(data map[string]string) {
	sql := "insert into search_users(created_at, updated_at, search_name, search_content, user_id) values (?,?,?,?,?)"
	_, err := global.App.DB.Exec(sql, time.Now(), time.Now(), data["search_name"], data["search_content"], data["user_id"])
	if driverErr, ok := err.(*mysql.MySQLError); ok {
		if driverErr.Number == 1062 {
			fmt.Println("重复数据：", err)
		} else {
			fmt.Println(err)
		}
	} else {
		fmt.Println("======新加入数据======：", data["search_name"])
	}
}
